import 'dart:convert';
import 'dart:io';

import 'package:device_info_plus/device_info_plus.dart';

import 'base_handler.dart';

class DeviceInfoHandler extends BaseHandler {

  @override
  String name = "deviceInfo";

  @override
  void handler(dynamic data, dynamic responseCallback) async {
    DeviceInfoPlugin deviceInfo = DeviceInfoPlugin();
    if(Platform.isIOS) {
      IosDeviceInfo info = await deviceInfo.iosInfo;
      responseCallback(jsonEncode(info.data));
    }else if(Platform.isAndroid) {
      AndroidDeviceInfo info = await deviceInfo.androidInfo;
      responseCallback(jsonEncode(info.data));
    }

  }
}